﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using UFIDA.U9.Base.Profile;
using UFIDA.U9.Base.Profile.Proxy;

namespace UFIDA.U9.Cust.XH.PlugBE.Tool
{ /// <summary>
  /// OAurl信息
  /// </summary>
    public class OAUrlHelper
    {
        //默认所有单据传送到OA的创建人
        public static string userId = "58";
        /// <summary>
        /// 1.许可证注册接口
        /// </summary>
        public static string registUrl = string.Format("{0}/api/ec/dev/auth/regist", OAUrl);
        /// <summary>
        /// 2.获取token接口
        /// </summary>
        public static string applytoken = string.Format("{0}/api/ec/dev/auth/applytoken", OAUrl);
        /// <summary>
        /// 3.流程新建接口
        /// </summary>
        public static string doCreateRequest = string.Format("{0}/api/workflow/paService/doCreateRequest", OAUrl);
        /// <summary>
        /// 流程提交接口
        /// </summary>
        public static string submitRequest = string.Format("{0}/api/workflow/paService/submitRequest", OAUrl);
        /// <summary>
        /// 4.获取人员信息（获取userid）接口地址
        /// </summary>
        public static string getHrmUserInfoWithPage = string.Format("{0}/api/hrm/resful/getHrmUserInfoWithPage", OAUrl);
        /// <summary>
        /// 获取分部
        /// </summary>
        public static string findHrmsubcompanyWithPage = string.Format("{0}/api/hrm/resful/getHrmsubcompanyWithPage", OAUrl);
        /// <summary>
        /// 获取部门
        /// </summary>
        public static string findHrmdepartmentWithPage = string.Format("{0}/api/hrm/resful/getHrmdepartmentWithPage", OAUrl);
        /// <summary>
        /// 同步部门
        /// </summary>
        public static string getDepUrl = string.Format("{0}/api/hrm/resful/synDepartment", OAUrl);
        public static string getCustUrl = string.Format("{0}/api/cube/restful/interface/saveOrUpdateModeData/khxx", OAUrl);
        public static string getSuppUrl = string.Format("{0}/api/cube/restful/interface/saveOrUpdateModeData/gysxx", OAUrl);
        public static string getProjUrl = string.Format("{0}/api/cube/restful/interface/saveOrUpdateModeData/xmxx", OAUrl);
        public static string getAccountjUrl = string.Format("{0}/api/cube/restful/interface/saveOrUpdateModeData/kmxx", OAUrl);
        public static string getSupplierUrl = string.Format("{0}//api/cube/restful/interface/getDataByPK/hkxx", OAUrl);
        /// <summary>
        /// 查询供应商
        /// </summary>
        public static string findSupplierUrl = string.Format("{0}/api/cube/restful/interface/getDataByPK/hkxx", OAUrl);
        /// <summary>
        /// 查询项目
        /// </summary>
        public static string findProjectUrl = string.Format("{0}/api/cube/restful/interface/getDataByPK/hqxmxx", OAUrl);
        /// <summary>
        /// 查询客户
        /// </summary>
        public static string findCustomerUrl = string.Format("{0}/api/cube/restful/interface/getDataByPK/hqkh", OAUrl);
 
        public static string OAUrl
        {
            get
            {
                string ProfileCode = "XAN_OAURL";
                GetProfileValueProxy bpObj = new GetProfileValueProxy();
                bpObj.ProfileCode = ProfileCode;
                PVDTOData pVTDOData = bpObj.Do();
                string val = pVTDOData.ProfileValue;
                if (string.IsNullOrEmpty(val))
                {
                    throw new Exception("获取OAUrl集成配置参数失败！请在系统参数中配置！");
                }

                return val;
            }


        }
        public static string Systemid
        {
            get
            {
                string ProfileCode = "XAN_OAAPPID";
                GetProfileValueProxy bpObj = new GetProfileValueProxy();
                bpObj.ProfileCode = ProfileCode;
                PVDTOData pVTDOData = bpObj.Do();
                string val = pVTDOData.ProfileValue;
                if (string.IsNullOrEmpty(val))
                {
                    throw new Exception("获取OAUrl集成配置参数失败！请在系统参数中配置！");
                }

                return val;
            }


        }
        public static string D_Password
        {
            get
            {
                string ProfileCode = "XAN_OACPK";
                GetProfileValueProxy bpObj = new GetProfileValueProxy();
                bpObj.ProfileCode = ProfileCode;
                PVDTOData pVTDOData = bpObj.Do();
                string val = pVTDOData.ProfileValue;
                if (string.IsNullOrEmpty(val))
                {
                    throw new Exception("获取OAUrl集成配置参数失败！请在Web.config配置文件中配置！");
                }

                return val;
            }


        }




        public static string GetMd5Hash(string str)
        {
            using (MD5 md5Obj = MD5.Create())
            {
                var md5Bytes = md5Obj.ComputeHash(Encoding.UTF8.GetBytes(str));
                //md5Obj.Dispose();
                StringBuilder builder = new StringBuilder();
                for (int i = 0; i < md5Bytes.Length; i++)
                {


                    builder.Append(md5Bytes[i].ToString("X2"));//3500元
                }
                return builder.ToString();
            }
        }



    }
}
